/**
 * Created by zhaojm on 15/4/3.
 */
game.BearEatPineConeEffect = cc.Class.extend({

    _sprite:null,
    _action : null,
    ctor:function(){

        var winSize = cc.winSize;

        this._sprite = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame('effect/4.png'));
        this._sprite.setAnchorPoint(cc.p(0.5, 0));




        //var frames = [];
        //for(var i = 1; i < 35; i++){
        //    var idx = '';
        //    if(i < 10){
        //        idx = '0' + i;
        //    }else {
        //        idx = i + '';
        //    }
        //    var frame = cc.spriteFrameCache.getSpriteFrame('explosion_' + idx + '.png');
        //    frames.push(frame);
        //}
        //var animation = new cc.Animation(frames, 0.04);
        //
        //var removeFunc =  cc.CallFunc.create(this.removeFromLayer);
        //
        //this._action = new cc.Sequence(new cc.Animate(animation), removeFunc);

    },

    addToLayer : function(layer, pos, scale){
        layer._spriteSheet.addChild(this._sprite, 2);
        this._sprite.setPosition(pos);
        this._sprite.setScale(scale);
        this._action = new cc.Sequence(
            /* new cc.Repeat(*/new cc.Animate(
                new cc.Animation([4, 5].map(function (i) {
                    return cc.spriteFrameCache.getSpriteFrame("effect/" + i + ".png");
                }), 0.05)
            ), //1),
            //new cc.CallFunc(callback),
            new cc.CallFunc(this.removeFromLayer)
        );
        this._sprite.runAction(this._action);
    },

    removeFromLayer : function(pSender){
        pSender.removeFromParent();
    },



});